﻿namespace ACCOUNTING
{
    using ACCOUNTING.LVY.Business;
    using ACCOUNTING.My.Resources;
    using C1.Win.C1FlexGrid;
    using C1.Win.C1FlexGrid.Util.BaseControls;
    using Microsoft.VisualBasic;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Diagnostics;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms;

    [DesignerGenerated]
    public class Frm_CapNhatGiaMua : Form
    {
        private static List<WeakReference> __ENCList = new List<WeakReference>();
        [AccessedThroughProperty("CboHangSanXuat")]
        private ComboBox _CboHangSanXuat;
        [AccessedThroughProperty("CboNhomHang")]
        private ComboBox _CboNhomHang;
        [AccessedThroughProperty("CmdCancel")]
        private Button _CmdCancel;
        [AccessedThroughProperty("Label1")]
        private Label _Label1;
        [AccessedThroughProperty("Label11")]
        private Label _Label11;
        [AccessedThroughProperty("Label2")]
        private Label _Label2;
        [AccessedThroughProperty("Label25")]
        private Label _Label25;
        [AccessedThroughProperty("Panel1")]
        private Panel _Panel1;
        [AccessedThroughProperty("Panel2")]
        private Panel _Panel2;
        [AccessedThroughProperty("Panel3")]
        private Panel _Panel3;
        [AccessedThroughProperty("TxtSearchMa")]
        private TextBox _TxtSearchMa;
        [AccessedThroughProperty("TxtSearchTen")]
        private TextBox _TxtSearchTen;
        [AccessedThroughProperty("VSlist")]
        private C1.Win.C1FlexGrid.C1FlexGrid _VSlist;
        private IContainer components;
        private bool mAllowAdd;
        private bool mAllowDel;
        private bool mAllowEdit;
        private bool mAllowView;
        private bool mHaveLoaded;
        private clsGiaMua objGM;
        private DataTable pData;
        private DataView pDtView;

        public Frm_CapNhatGiaMua()
        {
            base.Load += new EventHandler(this.Frm_CapNhatGia_Load);
            List<WeakReference> list = __ENCList;
            lock (list)
            {
                __ENCList.Add(new WeakReference(this));
            }
            this.objGM = new clsGiaMua();
            this.mHaveLoaded = false;
            this.InitializeComponent();
        }

        private void CboHangSanXuat_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.LoadData();
        }

        private void CboNhomHang_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.LoadData();
        }

        private void CmdCancel_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void CmdClose_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        [DebuggerNonUserCode]
        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void Frm_CapNhatGia_Load(object sender, EventArgs e)
        {
            LVYModule.GetUserRight(ref this.mAllowView, ref this.mAllowDel, ref this.mAllowEdit, ref this.mAllowAdd, Conversions.ToString(this.Tag), modGeneral.H_USERNAME);
            if (!this.mAllowView)
            {
                LVYModule.ShowWarning(modGeneral.Tranlated("Bạn kh\x00f4ng c\x00f3 quyền xem, li\x00ean hệ với người quản trị để biết th\x00eam chi tiết.", ""));
                this.Dispose();
            }
            else
            {
                this.mHaveLoaded = false;
                BuildComboModule.BuildCombo(this.CboNhomHang, modGeneral.ListDanhMuc.NhomHangHoa, true, "", "");
                BuildComboModule.BuildCombo(this.CboHangSanXuat, modGeneral.ListDanhMuc.HangSanXuat, true, "", "");
                this.mHaveLoaded = true;
                this.LoadData();
            }
        }

        [DebuggerStepThrough]
        private void InitializeComponent()
        {
            ComponentResourceManager manager = new ComponentResourceManager(typeof(Frm_CapNhatGiaMua));
            this.Label2 = new Label();
            this.Label1 = new Label();
            this.CmdCancel = new Button();
            this.TxtSearchTen = new TextBox();
            this.Label11 = new Label();
            this.TxtSearchMa = new TextBox();
            this.Label25 = new Label();
            this.CboHangSanXuat = new ComboBox();
            this.VSlist = new C1.Win.C1FlexGrid.C1FlexGrid();
            this.Panel1 = new Panel();
            this.Panel2 = new Panel();
            this.CboNhomHang = new ComboBox();
            this.Panel3 = new Panel();
            this.VSlist.BeginInit();
            this.Panel1.SuspendLayout();
            this.Panel2.SuspendLayout();
            this.Panel3.SuspendLayout();
            this.SuspendLayout();
            this.Label2.AutoSize = true;
            this.Label2.BackColor = Color.Transparent;
            Point point = new Point(0x68, 0x18);
            this.Label2.Location = point;
            this.Label2.Name = "Label2";
            Size size = new Size(0x2a, 13);
            this.Label2.Size = size;
            this.Label2.TabIndex = 0x42;
            this.Label2.Text = "&T\x00ecm t\x00ean";
            this.Label2.TextAlign = ContentAlignment.TopRight;
            this.Label1.AutoSize = true;
            this.Label1.BackColor = Color.Transparent;
            point = new Point(0, 0x18);
            this.Label1.Location = point;
            this.Label1.Name = "Label1";
            size = new Size(0x29, 13);
            this.Label1.Size = size;
            this.Label1.TabIndex = 0x40;
            this.Label1.Text = "T\x00ecm &m\x00e3";
            this.Label1.TextAlign = ContentAlignment.TopRight;
            this.CmdCancel.BackColor = SystemColors.Control;
            this.CmdCancel.DialogResult = DialogResult.Cancel;
            this.CmdCancel.Image = ACCOUNTING.My.Resources.Resources.Closed;
            this.CmdCancel.ImageAlign = ContentAlignment.MiddleLeft;
            point = new Point(7, 12);
            this.CmdCancel.Location = point;
            this.CmdCancel.Name = "CmdCancel";
            size = new Size(0x49, 0x18);
            this.CmdCancel.Size = size;
            this.CmdCancel.TabIndex = 0;
            this.CmdCancel.Text = "Th&o\x00e1t";
            this.CmdCancel.UseVisualStyleBackColor = false;
            point = new Point(0x6c, 3);
            this.TxtSearchTen.Location = point;
            this.TxtSearchTen.Name = "TxtSearchTen";
            size = new Size(0xf8, 20);
            this.TxtSearchTen.Size = size;
            this.TxtSearchTen.TabIndex = 1;
            this.Label11.AutoSize = true;
            this.Label11.BackColor = Color.Transparent;
            this.Label11.ForeColor = SystemColors.ActiveCaption;
            point = new Point(4, 4);
            this.Label11.Location = point;
            this.Label11.Name = "Label11";
            size = new Size(0x53, 13);
            this.Label11.Size = size;
            this.Label11.TabIndex = 0x3b;
            this.Label11.Text = "&Nh\x00f3m h\x00e0ng h\x00f3a";
            this.Label11.TextAlign = ContentAlignment.TopRight;
            point = new Point(3, 3);
            this.TxtSearchMa.Location = point;
            this.TxtSearchMa.Name = "TxtSearchMa";
            size = new Size(0x67, 20);
            this.TxtSearchMa.Size = size;
            this.TxtSearchMa.TabIndex = 0;
            this.Label25.AutoSize = true;
            this.Label25.BackColor = Color.Transparent;
            this.Label25.ForeColor = Color.Black;
            point = new Point(0xcc, 7);
            this.Label25.Location = point;
            this.Label25.Name = "Label25";
            size = new Size(0x4c, 13);
            this.Label25.Size = size;
            this.Label25.TabIndex = 0x3e;
            this.Label25.Text = "H\x00e3ng sản xuất";
            this.CboHangSanXuat.DropDownStyle = ComboBoxStyle.DropDownList;
            this.CboHangSanXuat.FormattingEnabled = true;
            point = new Point(0xcf, 0x16);
            this.CboHangSanXuat.Location = point;
            this.CboHangSanXuat.Name = "CboHangSanXuat";
            size = new Size(0xbb, 0x15);
            this.CboHangSanXuat.Size = size;
            this.CboHangSanXuat.TabIndex = 1;
            this.VSlist.BorderStyle = C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.FixedSingle;
            this.VSlist.ColumnInfo = manager.GetString("VSlist.ColumnInfo");
            this.VSlist.Dock = DockStyle.Fill;
            this.VSlist.ExtendLastCol = true;
            this.VSlist.FocusRect = FocusRectEnum.Solid;
            this.VSlist.KeyActionEnter = KeyActionEnum.MoveAcross;
            point = new Point(0, 0x36);
            this.VSlist.Location = point;
            Padding padding = new Padding(0);
            this.VSlist.Margin = padding;
            this.VSlist.Name = "VSlist";
            this.VSlist.Rows.Count = 1;
            this.VSlist.Rows.DefaultSize = 0x11;
            this.VSlist.ShowCellLabels = true;
            size = new Size(0x25f, 0x1ac);
            this.VSlist.Size = size;
            this.VSlist.StyleInfo = manager.GetString("VSlist.StyleInfo");
            this.VSlist.TabIndex = 0;
            this.VSlist.VisualStyle = VisualStyle.Office2007Blue;
            this.Panel1.BackgroundImage = ACCOUNTING.My.Resources.Resources.bgbluenoborder;
            this.Panel1.BackgroundImageLayout = ImageLayout.Stretch;
            this.Panel1.Controls.Add(this.Label25);
            this.Panel1.Controls.Add(this.CboHangSanXuat);
            this.Panel1.Controls.Add(this.Panel2);
            this.Panel1.Controls.Add(this.CboNhomHang);
            this.Panel1.Controls.Add(this.Label11);
            this.Panel1.Dock = DockStyle.Top;
            point = new Point(0, 0);
            this.Panel1.Location = point;
            this.Panel1.Name = "Panel1";
            size = new Size(0x25f, 0x36);
            this.Panel1.Size = size;
            this.Panel1.TabIndex = 0x15;
            this.Panel2.BackColor = Color.Transparent;
            this.Panel2.Controls.Add(this.CmdCancel);
            this.Panel2.Dock = DockStyle.Right;
            point = new Point(0x20b, 0);
            this.Panel2.Location = point;
            this.Panel2.Name = "Panel2";
            size = new Size(0x54, 0x36);
            this.Panel2.Size = size;
            this.Panel2.TabIndex = 60;
            this.CboNhomHang.DropDownStyle = ComboBoxStyle.DropDownList;
            this.CboNhomHang.FormattingEnabled = true;
            point = new Point(8, 0x16);
            this.CboNhomHang.Location = point;
            this.CboNhomHang.Name = "CboNhomHang";
            size = new Size(0xc1, 0x15);
            this.CboNhomHang.Size = size;
            this.CboNhomHang.TabIndex = 0;
            this.Panel3.BackgroundImage = ACCOUNTING.My.Resources.Resources.BgBlue;
            this.Panel3.BackgroundImageLayout = ImageLayout.Stretch;
            this.Panel3.Controls.Add(this.Label2);
            this.Panel3.Controls.Add(this.Label1);
            this.Panel3.Controls.Add(this.TxtSearchTen);
            this.Panel3.Controls.Add(this.TxtSearchMa);
            this.Panel3.Dock = DockStyle.Bottom;
            point = new Point(0, 0x1e2);
            this.Panel3.Location = point;
            this.Panel3.Name = "Panel3";
            size = new Size(0x25f, 40);
            this.Panel3.Size = size;
            this.Panel3.TabIndex = 0x17;
            SizeF ef = new SizeF(6f, 13f);
            this.AutoScaleDimensions = ef;
            this.AutoScaleMode = AutoScaleMode.Font;
            size = new Size(0x25f, 0x20a);
            this.ClientSize = size;
            this.ControlBox = false;
            this.Controls.Add(this.VSlist);
            this.Controls.Add(this.Panel1);
            this.Controls.Add(this.Panel3);
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            this.KeyPreview = true;
            this.Name = "Frm_CapNhatGiaMua";
            this.Tag = "MH-0011";
            this.Text = "CAP NHAT GIA DAU VAO";
            this.VSlist.EndInit();
            this.Panel1.ResumeLayout(false);
            this.Panel1.PerformLayout();
            this.Panel2.ResumeLayout(false);
            this.Panel3.ResumeLayout(false);
            this.Panel3.PerformLayout();
            this.ResumeLayout(false);
        }

        public void LoadData()
        {
            if (this.mHaveLoaded)
            {
                this.Cursor = Cursors.WaitCursor;
                int num = 0;
                clsDMLoaiTien tien = new clsDMLoaiTien();
                this.VSlist.DataSource = null;
                this.VSlist.Rows.Count = 1;
                this.pData = this.objGM.GetList(LVYModule.ReturnIfNull(RuntimeHelpers.GetObjectValue(this.CboNhomHang.SelectedValue), "", modGeneral.TypeOfValue.Nothing).ToString().Trim(), LVYModule.ReturnIfNull(RuntimeHelpers.GetObjectValue(this.CboHangSanXuat.SelectedValue), "", modGeneral.TypeOfValue.Nothing).ToString().Trim());
                this.pDtView = new DataView(this.pData);
                this.VSlist.DataSource = this.pDtView;
                this.VSlist.Cols[0].Visible = false;
                this.VSlist.Cols[1].Width = 100;
                this.VSlist.Cols[2].Width = 240;
                this.VSlist[0, 1] = modGeneral.Tranlated("M\x00e3 h\x00e0ng h\x00f3a", "");
                this.VSlist[0, 2] = modGeneral.Tranlated("T\x00ean h\x00e0ng h\x00f3a", "");
                this.VSlist[0, 3] = modGeneral.Tranlated("Đơn vị t\x00ednh", "");
                int num2 = this.VSlist.Cols.Count - 1;
                for (num = 4; num <= num2; num++)
                {
                    this.VSlist.Cols[num].Width = 100;
                    string strCode = LVYModule.ReturnIfNull(RuntimeHelpers.GetObjectValue(this.VSlist[0, num]), "", modGeneral.TypeOfValue.Nothing).ToString().Trim();
                    tien.LoadByCode(strCode);
                    this.VSlist.Cols[num].DataType = System.Type.GetType("System.Decimal");
                    this.VSlist.Cols[num].Format = modGeneral.H_FORMATNUMBER + "." + LVYModule.sRight("0000000000", tien.SoLe);
                }
                this.VSlist.Cols[this.VSlist.Cols.Count - 1].Width = 80;
                this.VSlist.Styles.Alternate.BackColor = ProfessionalColors.ToolStripGradientMiddle;
                this.Cursor = Cursors.Default;
                this.CenterToScreen();
            }
        }

        public bool SaveData(int nRow, int nCol)
        {
            bool flag=false;
            clsDMLoaiTien tien = new clsDMLoaiTien();
            string strCode = LVYModule.ReturnIfNull(RuntimeHelpers.GetObjectValue(this.VSlist[0, nCol]), "", modGeneral.TypeOfValue.Nothing).ToString().Trim();
            tien.LoadByCode(strCode);
            clsGiaMua objGM = this.objGM;
            objGM.KhoaHangHoa = Conversions.ToString(this.VSlist[nRow, 0]);
            objGM.LoaiTien = Conversions.ToString(this.VSlist[0, nCol]);
            objGM.GiaMua = Conversions.ToDouble(LVYModule.ReturnIfNull(RuntimeHelpers.GetObjectValue(this.VSlist[nRow, nCol]), 0, modGeneral.TypeOfValue.Nothing));
            objGM.KhoaNhanVienCapNhat = modGeneral.H_USERID;
            objGM.NgayBatDau = LVYModule.Date2Char(Strings.Format(DateAndTime.Today, "dd/MM/yyyy"));
            objGM.TienViet = tien.TienViet;
            return objGM.SaveData();
            objGM = null;
            return flag;
        }

        public void Search(string strCode, string strName)
        {
            string left = "";
            if (strCode.Trim() != "")
            {
                left = "Ma LIKE '" + strCode + "%'";
            }
            if (strName.Trim() != "")
            {
                left = Conversions.ToString(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(left, Interaction.IIf(left.Trim() != "", " And TenHang LIKE '" + strName + "%'", " Ten LIKE '" + strName + "%'")));
            }
            this.pDtView.RowFilter = left;
            if (this.VSlist.Rows.Count != 1)
            {
                this.VSlist.Select(1, 0, 1, this.VSlist.Cols.Count - 1);
            }
        }

        private void TxtSearchMa_TextChanged(object sender, EventArgs e)
        {
            this.Search(this.TxtSearchMa.Text, this.TxtSearchTen.Text);
        }

        private void TxtSearchTen_TextChanged(object sender, EventArgs e)
        {
            this.Search(this.TxtSearchMa.Text, this.TxtSearchTen.Text);
        }

        private void VSlist_AfterEdit(object sender, RowColEventArgs e)
        {
            this.SaveData(e.Row, e.Col);
        }

        private void VSlist_BeforeEdit(object sender, RowColEventArgs e)
        {
            if (e.Col < 4)
            {
                e.Cancel = true;
            }
        }

        internal virtual ComboBox CboHangSanXuat
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CboHangSanXuat;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CboHangSanXuat_SelectedIndexChanged);
                if (this._CboHangSanXuat != null)
                {
                    this._CboHangSanXuat.SelectedIndexChanged -= handler;
                }
                this._CboHangSanXuat = value;
                if (this._CboHangSanXuat != null)
                {
                    this._CboHangSanXuat.SelectedIndexChanged += handler;
                }
            }
        }

        internal virtual ComboBox CboNhomHang
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CboNhomHang;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CboNhomHang_SelectedIndexChanged);
                if (this._CboNhomHang != null)
                {
                    this._CboNhomHang.SelectedIndexChanged -= handler;
                }
                this._CboNhomHang = value;
                if (this._CboNhomHang != null)
                {
                    this._CboNhomHang.SelectedIndexChanged += handler;
                }
            }
        }

        internal virtual Button CmdCancel
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdCancel;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CmdCancel_Click);
                if (this._CmdCancel != null)
                {
                    this._CmdCancel.Click -= handler;
                }
                this._CmdCancel = value;
                if (this._CmdCancel != null)
                {
                    this._CmdCancel.Click += handler;
                }
            }
        }

        internal virtual Label Label1
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label1;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label1 = value;
            }
        }

        internal virtual Label Label11
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label11;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label11 = value;
            }
        }

        internal virtual Label Label2
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label2;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label2 = value;
            }
        }

        internal virtual Label Label25
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label25;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label25 = value;
            }
        }

        internal virtual Panel Panel1
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Panel1;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Panel1 = value;
            }
        }

        internal virtual Panel Panel2
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Panel2;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Panel2 = value;
            }
        }

        internal virtual Panel Panel3
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Panel3;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Panel3 = value;
            }
        }

        internal virtual TextBox TxtSearchMa
        {
            [DebuggerNonUserCode]
            get
            {
                return this._TxtSearchMa;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.TxtSearchMa_TextChanged);
                if (this._TxtSearchMa != null)
                {
                    this._TxtSearchMa.TextChanged -= handler;
                }
                this._TxtSearchMa = value;
                if (this._TxtSearchMa != null)
                {
                    this._TxtSearchMa.TextChanged += handler;
                }
            }
        }

        internal virtual TextBox TxtSearchTen
        {
            [DebuggerNonUserCode]
            get
            {
                return this._TxtSearchTen;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.TxtSearchTen_TextChanged);
                if (this._TxtSearchTen != null)
                {
                    this._TxtSearchTen.TextChanged -= handler;
                }
                this._TxtSearchTen = value;
                if (this._TxtSearchTen != null)
                {
                    this._TxtSearchTen.TextChanged += handler;
                }
            }
        }

        internal virtual C1.Win.C1FlexGrid.C1FlexGrid VSlist
        {
            [DebuggerNonUserCode]
            get
            {
                return this._VSlist;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                RowColEventHandler handler = new RowColEventHandler(this.VSlist_BeforeEdit);
                RowColEventHandler handler2 = new RowColEventHandler(this.VSlist_AfterEdit);
                if (this._VSlist != null)
                {
                    this._VSlist.BeforeEdit -= handler;
                    this._VSlist.AfterEdit -= handler2;
                }
                this._VSlist = value;
                if (this._VSlist != null)
                {
                    this._VSlist.BeforeEdit += handler;
                    this._VSlist.AfterEdit += handler2;
                }
            }
        }
    }
}

